using DimensionsHelper.LanguageService.Symbols;
using DimensionsHelper.LanguageService.Syntax;

namespace DimensionsHelper.LanguageService;

public class AnalysisLocalVariable : AnalysisDeclaration
{
    internal AnalysisLocalVariable(VariableDeclaration syntaxNode,
        AnalysisNode? parent) : base(AnalysisBoundKinds.LocalVariable, syntaxNode, parent)
    {
        Syntax = syntaxNode;
    }

    public override VariableDeclaration Syntax { get; }
}

public static partial class AnalysisNodeFactory
{
    /// <summary>
    /// 创建一个本地变量声明
    /// </summary>
    /// <param name="declaration">原始语法节点</param>
    /// <param name="parent">父节点，可以忽略</param>
    /// <param name="withSymbol">语法节点所在的With语句上下文类型符号</param>
    public static AnalysisLocalVariable LocalVariable(VariableDeclaration declaration, AnalysisNode? parent,
        ITypeSymbol? withSymbol)
    {
        return new AnalysisLocalVariable(declaration, parent).WithContainingWithSymbol(withSymbol);
    }
}